recordfield id 214 ,recordfield id 215 ,recordfield id 216 ,recordfield id 217 ,recordfield id 218 ,recordfield id 219 ,recordfield id 220 ,recordfield id 221 ,recordfield id 222 ,recordfield id 223 ,recordfield id 224 ,recordfield id 225 ,recordfield id 226 ,recordfield id 227 ,recordfield id 228 ,recordfield id 229 ,recordfield id 230 ,recordfield id 231 ,recordfield id 232 ,recordfield id 233 ,recordfield id 234 ,recordfield id 235 ,recordfield id 236 ,recordfield id 237 ,recordfield id 238 ,recordfield id 239 ,recordfield id 240 ,recordfield id 241 ,recordfield id 242 ,recordfield id 243
4ox, oy, moved, prevpos
4ox, oy
H0, ty - oy
getcurrenttime()
H200,0
"This took" && getTime(
) && "
buttonstilldown
buttondown
buttonup
buttondoubleclick
buttondown
moved
prevpos
buttonstilldown
buttonup
buttonstilldown
buttondoubleclick
getcurrenttime
This took
getTime
seconds to move.
moved
prevpos
Does It Matter Where Objects Are?The Background
Drag the arrow to a row of objects, then double click it.
buttonup
buttonup
response
Aw geeOkaylreadyr me?ha ha ha
This tests redrawing of objects on the background and page.
The bottom two rows are draw objects on the page and background.
4ox, oy, moved, prevpos
4ox, oy
H0, ty - oy
getcurrenttime()
H200,0
"This took" && getTime(
) && "
buttonstilldown
buttondown
buttonup
buttondoubleclick
buttondown
moved
prevpos
buttonstilldown
buttonup
buttonstilldown
buttondoubleclick
getcurrenttime
This took
getTime
seconds to move.
moved
prevpos
There
4ox, oy, moved, prevpos
4ox, oy
H0, ty - oy
getcurrenttime()
H200,0
"This took" && getTime(
) && "
buttonstilldown
buttondown
buttonup
buttondoubleclick
buttondown
moved
prevpos
buttonstilldown
buttonup
buttonstilldown
buttondoubleclick
getcurrenttime
This took
getTime
seconds to move.
moved
prevpos
flipper
afterflip
enterpage
enterpage
"Now
good men
come
their country."
getcurrenttime()
"It took" && getTime(
) && "
buttonup
buttonup
Now is the time for all good men to come to the aid of their country.
getcurrenttime
It took
getTime
seconds to do this.
An Opaque Overlapping Field
"Now
good men
come
their country."
getcurrenttime()
"It took" && getTime(
) && "
buttonup
buttonup
Now is the time for all good men to come to the aid of their country.
getcurrenttime
It took
getTime
seconds to do this.
A Transparent Overlapping Field
"Now
good men
come
their country."
getcurrenttime()
"It took" && getTime(
) && "
buttonup
buttonup
Now is the time for all good men to come to the aid of their country.
getcurrenttime
It took
getTime
seconds to do this.
An Opaque Field
"Now
good men
come
their country."
getcurrenttime()
"It took" && getTime(
) && "
buttonup
buttonup
Now is the time for all good men to come to the aid of their country.
getcurrenttime
It took
getTime
seconds to do this.
A Transparent Field
Be Careful How You Place Fieldsdssssss
The speed of typing or of displaying text through OpenScript can vary greatly: :, depending on:
getcurrenttime()
"It only took" && getTime(
) && "
a list
100 things."
buttonup
buttonup
getcurrenttime
It only took
getTime
seconds to pop a list of 100 things.
The Right Way --> Pop
getcurrenttime()
"That was" && getTime(
) && "
iterate through a list
100 things."
buttonup
buttonup
getcurrenttime
That was
getTime
seconds to iterate through a list of 100 things.
The Wrong Way --> Item
An Obscure Concept: Pop, Don't Steptep
When referring to items in a comma-separated list, don't step through items by saying "item i of foo". Instead just pop a working copy of the list until it's null.
to handle buttonup
system realList
local wrkList
set wrkList to realList
while wrkList is not null
pop wrkList
--do something with IT here
end
to handle buttonup
system realList
step i from 1 to itemcount(realList)
get item i of realList
--do something with IT here
end
end
Some Common Sense.... Sense...
Use a common background for similar pages
Minimize the number of objects on the page and background
Group objects only when your scripts require it
Clip bitmaps to as small a size as possible
Clean up your books before distributing themed rectangular ones
Avoid overlapping objects such as data fields and their labels
Use a background pattern of none if you're brave
Don't wrap text in fields if you can instead fit it all on one lineve
Don't wrap text in fields if you can instead fit it all on one linerap text in fields if you can instead fit it all on one line
Maybe These Aren't So Obvious...o
Cache property values and object references into variables
"Clear" properties or variables instead of setting them to null
Put keyDown/Up/Char handlers only where they're needed
Limit code in your Idle handler
Use the "character" string specifier over "word" or textline"
Pre-flip pages before showing the main windowowwndown windowwre showing the main window
"cache"
"udp"
terpage
leavepage
enterpage
enterpage
leavepage
cache
"cache"
getcurrenttime()
"It only took" && getTime(
) && "
refer
a property value that was cached
buttonup
buttonup
cache
getcurrenttime
It only took
getTime
seconds to refer to a property value that was cached in a local variable.
Cache A Property
getcurrenttime()
"However
took" && getTime(
) && "
refer directly
a default property 2000 times."
buttonup
buttonup
getcurrenttime
However it took
getTime
seconds to refer directly to a default property 2000 times.
Refer To A Default Property
Referring to Properties vs. Caching Them
If you need to refer to a property of an object more than once in a handler, or series of handlers, it will be much faster to set a variable to that value, and then refer to that variable instead of the property. This is especially true for user-defined properties, which take twice as long to get as default properties do.
"udp"
getcurrenttime()
"And
took" && getTime(
) && "
refer
a user-defined property 2000 times."
buttonup
buttonup
getcurrenttime
And it took
getTime
seconds to refer to a user-defined property 2000 times.
Refer To A User-Defined Property
cache
to handle buttonup
set bar to name of this page
step i from 1 to 2000
set foo to bar
end
end
set syscursor to 1
foo to t
end
beep 1
set syscursor to 1
to handle buttonup
step i from 1 to 2000
set foo to name of this page
end
set syscursor to 1
of this page
end
beep 1
set syscursor to 1
et syscursor to 1
to handle buttonup
step i from 1 to 2000
set foo to bar of this page
end
i from 1 to 2000
set xoo to foo of this page
end
set syscursor to 1
et syscursor to 1
yellow
getcurrenttime()
"It took" && (
)/1000 && "
a message
here."
buttonup
buttonup
getcurrenttime
It took
getcurrenttime
seconds for a message to get here.
Send Message (Book Handler)
getcurrenttime()
"It took" && getTime(
) && "
a message
up the hierarchy
1000 times."
buttonup
buttonup
getcurrenttime
It took
getTime
seconds for a message to float up the hierarchy to the book script 1000 times.
Send Message (Book Handler)
getcurrenttime()
"It took" && getTime(
) && "
a message
up the hierarchy
1000 times."
buttonup
buttonup
getcurrenttime
^}mbg
It took
getTime
seconds for a message to float up the hierarchy to the background script 1000 times.
Send Message (Background Handler)
getcurrenttime()
"It took" && getTime(
) && "
a message
up the hierarchy
1000 times."
buttonup
buttonup
getcurrenttime
It took
getTime
seconds for a message to float up the hierarchy to the page script 1000 times.
Send Message (Page Handler)
getcurrenttime()
"It took" && getTime(
) && "
a message
be sent directly
1000 times."
buttonup
buttonup
getcurrenttime
It took
getTime
seconds for a message to be sent directly to the book script 1000 times.
Send Directly To Book Handler
getcurrenttime()
"It took" && getTime(
) && "
a message
be sent directly
1000 times."
buttonup
buttonup
getcurrenttime
o^}mbg
It took
getTime
seconds for a message to be sent directly to the background script 1000 times.
Send Directly To Background Handler
getcurrenttime()
"It took" && getTime(
) && "
a message
be sent directly
1000 times."
buttonup
buttonup
getcurrenttime
oi_mp
It took
getTime
seconds for a message to be sent directly to the page script 1000 times.
Send Directly To Page Handler
The Hierarchy And Message Passing
Where should you put your scripts? This should give you a clue. The yellow button does the same as the top green button, but from the bottom of a deeply nested group.oup.
enterpage
leavepage
enterpage
leavepage
getcurrenttime()
H15,0
"It took" && getTime(
) && "
on the
200 times
Hreferencing
directly."
105,4500
buttonup
buttonup
getcurrenttime
It took
getTime
seconds to move a rectangle on the page 200 times by referencing it directly.
Reference a Page Object
Referring to Objects vs. Caching Themhem
Just as caching a property value into a varible increases performance, so will caching a refence to an object. For instance you can say:
set foo to button "total" of this background.
Then refence foo instead of the button. It'll be alot faster.properties, which take twice as long to get as default properties do.
getcurrenttime()
H15,0
"It took" && getTime(
) && "
on the
200 times
caching a reference
105,4500
buttonup
buttonup
getcurrenttime
It took
getTime
seconds to move a rectangle on the page 200 times after caching a reference to it.
Reference a Cached Page Object
getcurrenttime()
H15,0
"It took" && getTime(
) && "
on the
/200 times
Hreferencing
directly."
105,4800
buttonup
buttonup
getcurrenttime
It took
getTime
seconds to move a rectangle on the background 200 times by referencing it directly.
Reference a Background Object
getcurrenttime()
H15,0
"It took" && getTime(
) && "
on the
/200 times
caching a reference
105,4800
buttonup
buttonup
getcurrenttime
It took
getTime
seconds to move a rectangle on the background 200 times after caching a reference to it.
Reference a Cached Background Object
moregroup
morelist
leavepage
leavepage
morelist
moregroup
/B3L6
field id 302 of page id 37,field id 303 of page id 37,field id 304 of page id 37,field id 305 of page id 37,field id 306 of page id 37,field id 307 of page id 37,field id 308 of page id 37,field id 309 of page id 37,field id 310 of page id 37,field id 311 of page id 37,field id 312 of page id 37,field id 313 of page id 37,field id 314 of page id 37,field id 315 of page id 37,field id 316 of page id 37,field id 317 of page id 37,field id 318 of page id 37,field id 319 of page id 37,field id 320 of page id 37,field id 321 of page id 37,field id 322 of page id 37
rectangle id 247 of page id 37,rectangle id 248 of page id 37,rectangle id 249 of page id 37,rectangle id 250 of page id 37,rectangle id 251 of page id 37,rectangle id 252 of page id 37,rectangle id 253 of page id 37,rectangle id 254 of page id 37,rectangle id 255 of page id 37,rectangle id 256 of page id 37,rectangle id 257 of page id 37,rectangle id 258 of page id 37,rectangle id 259 of page id 37,rectangle id 260 of page id 37,rectangle id 261 of page id 37,rectangle id 262 of page id 37,rectangle id 263 of page id 37,rectangle id 264 of page id 37,rectangle id 265 of page id 37,rectangle id 266 of page id 37,rectangle id 267 of page id 37,rectangle id 268 of page id 37,rectangle id 269 of page id 37,rectangle id 270 of page id 37,rectangle id 271 of page id 37,rectangle id 272 of page id 37,rectangle id 273 of page id 37,rectangle id 274 of page id 37,rectangle id 275 of page id 37,rectangle id 276 of page id 37,rectangle id 277 of page id 37,rectangle id 278 of page id 37,rectangle id 279 of page id 37,rectangle id 280 of page id 37,rectangle id 281 of page id 37,rectangle id 282 of page id 37,rectangle id 283 of page id 37,rectangle id 284 of page id 37,rectangle id 285 of page id 37,rectangle id 286 of page id 37,rectangle id 287 of page id 37,rectangle id 288 of page id 37,rectangle id 289 of page id 37,rectangle id 290 of page id 37,rectangle id 291 of page id 37,rectangle id 292 of page id 37,rectangle id 293 of page id 37,rectangle id 294 of page id 37,rectangle id 295 of page id 37,rectangle id 296 of page id 37,rectangle id 297 of page id 37,rectangle id 298 of page id 37,rectangle id 299 of page id 37,rectangle id 300 of page id 37
field id 123 of page id 37,field id 124 of page id 37,field id 125 of page id 37,field id 126 of page id 37,field id 127 of page id 37,field id 128 of page id 37,field id 129 of page id 37,field id 130 of page id 37,field id 131 of page id 37,field id 132 of page id 37,field id 133 of page id 37,field id 134 of page id 37,field id 135 of page id 37,field id 136 of page id 37,field id 144 of page id 37,field id 145 of page id 37,field id 146 of page id 37,field id 147 of page id 37,field id 148 of page id 37,field id 149 of page id 37,field id 150 of page id 37,field id 151 of page id 37,field id 152 of page id 37,field id 153 of page id 37,field id 154 of page id 37,field id 155 of page id 37,field id 156 of page id 37,field id 157 of page id 37,field id 158 of page id 37,field id 159 of page id 37,field id 160 of page id 37,field id 161 of page id 37,field id 162 of page id 37,field id 163 of page id 37,field id 164 of page id 37,field id 165 of page id 37,field id 166 of page id 37,field id 167 of page id 37,field id 168 of page id 37,field id 169 of page id 37,field id 170 of page id 37,field id 171 of page id 37,field id 172 of page id 37,field id 173 of page id 37,field id 174 of page id 37,field id 175 of page id 37,field id 176 of page id 37,field id 177 of page id 37,field id 178 of page id 37,field id 179 of page id 37,field id 180 of page id 37,field id 181 of page id 37,field id 182 of page id 37,field id 183 of page id 37,field id 184 of page id 37,field id 185 of page id 37,field id 186 of page id 37,field id 187 of page id 37,field id 188 of page id 37,field id 189 of page id 37,field id 190 of page id 37,field id 191 of page id 37,field id 192 of page id 37,field id 193 of page id 37,field id 194 of page id 37,field id 195 of page id 37,field id 196 of page id 37,field id 197 of page id 37,field id 205 of page id 37,field id 206 of page id 37,field id 207 of page id 37,field id 208 of page id 37,field id 209 of page id 37,field id 210 of page id 37,field id 211 of page id 37,field id 212 of page id 37,field id 213 of page id 37,field id 214 of page id 37,field id 215 of page id 37,field id 216 of page id 37,field id 217 of page id 37,field id 218 of page id 37,field id 219 of page id 37,field id 220 of page id 37,field id 221 of page id 37
Using Groups And Lists Of Object References Speed
explanation
Stuff In A Group
The GroupA Group
buttonup
buttonup
When you assign a property value to a group, that value propagates on down to the objects of the group.
120,50,100
0,50,100
60,50,100
240,50,100
0,100,0
0,0,0
180,50,100
300,50,100
country
ll > 0
getcurrenttime()
B"a"
B"b"
B"c"
"This took" && getTime(
) && "
buttonup
buttonup
textfrompoint
getcurrenttime
This took
getTime
seconds.
i:to1
System
Terminal
Courier
Tms Rmn
Symbol
Roman
Scriptnnnnnnnn
ll > 0
getcurrenttime()
B"a"
B"b"
B"c"
"This took" && getTime(
) && "
buttonup
buttonup
textfrompoint
getcurrenttime
This took
getTime
seconds.
i:to1
Green
Yellow
White
Black
Magenta
buttonup
buttonup
As Individual Items
As A List Of Items
As A Group
moregroup
buttonup
buttonup
moregroup
morelist
buttonup
buttonup
morelist
morelist
Lists of object references can be very handy. As an author tool, the system variable Selection is great to use for setting properties of many objects at once. Just select all the objects that you want to change and then set a property of Selection to whatever value you want. That value will propagate on down to all the objects in selection.
If you want to clear or set the text of many recordfields, use a list of references to the recordfields without the "of background" specifier in each reference.....
buttonup
buttonup
moregroup
One good use for groups is controlling the checking of a series of radio buttons. If you group a set of related radio buttons, you can then set the checked property of that group to FALSE. All the radio buttons will become unchecked. An example of the radio button group's script might be:
to handle buttonup
set my checked to FALSE
set checked of target to TRUE
endUE
endenddUE
buttonup
buttonup
You can set properties of many objects at the same time by making a list of object references to all the objects, and then setting a property of the list, or grouping all the objects and then setting the property of the group, even if that property isn't a default property for a group.
grouping all the objects and then setting the property of the group, even if that property isn't a default property for a group.
Click a radio button, and then one of the green shadowed fields to see the difference.e group, even if that property isn't a default property for a group.
Click a radio button, and then a green shadowed field to see the difference..fference...ty isn't a default property for a group.
Click a radio button, and then one of the green shadowed fields to see the difference.e group, even if that property isn't a default property for a group.
"test"
getcurrenttime()
o(48 +
(80))
"It took" && getTime(
) && "
buttonup
buttonup
getcurrenttime
It took
getTime
seconds to do this.
The Cost of Character and Paragraph Properties
Character and paragraph properties have an effect on the speed of displaying text. The Test button on this page puts 200 random characters after the text of the yellow field. Set character and paragraph properties of the yellow field with the two green buttons, and then click the test button.
These statistics were found by creating an empty book, drawing an object, and then saving the book. A seperate book was saved for each kind of object. An empty book was 6588 bytes. Note that this may not be completely reliable, but it does give you some indication of the cost of each object type.
buttonup
buttonup
System
hD|D|
`D|D|
`D|D|
Tms Rmn
`D|D|
`D|D|
Optimizing Your ToolBook Apps
s Rmn
hD|D|
s Rmn
hD|D|
s Rmn
hD|D|
s Rmn
hD|D|
hD|D|
hD|D|
hD|D|
hD|D|
hD|D|
hD|D|
fOldTime
s Rmn
hD|D|
4svHaHa
X"user.exe"
DWORD getcurrenttime()
getTime fOldTime
)/1000
%"#.00"
enterbook
getTime
enterbook
sizetopage
seconds
user.exe
getcurrenttime
svHaHa
getTime
getcurrenttime
fOldTime
hD|D|
hD|D|
hD|D|
hD|D|
gD|D|
system
hD|D|
Tms Rmn
gD|D|
Modern
hD|D|
buttonup
buttonup
response
I'm shufflin'dyr me?ha ha ha
k8 = 0
"brows"
H0,-50
H0,50
H0,-50
H0,50
k2 = 0
brows
brows
brows
brows
brows
bigsmile
Button
A Carelessly Built Bookok
Efficient Clean
Concise Book
Defunct User
Defined Properties
Old Hidden
Objects
Unused
Unnecessary references to proper+
Overlapping
Objects
Unnecessary references to property values
Will your books ever be as fast as this Zillion Dollar Car?Could Be Your Bookk
404V4|4
7(8P8
B<BjB
C4ChC
D8DlD
EDEzE
F*G`G
H8HnH
H&ITI
J8JdJ
K@K~K
frame2
setup
4currmo, curryear, stilldown,
B"bmobutton"
%"m"
B"byrbutton"
buildcal m, y
Ztotdays, wrkday, i
getcurrenttime()
weekDay(1, m, y)
T - 1
B("b" & i)
daysInMonth(m)
B("b" &
B("b" & i)
"Whew!
It took me" && getTime(
) && "
d, m, y
4leapyear
Zmfactor, cfactor
Zday1, yr
k4 = 0
k100 <> 0)
k400 = 0)
"034025036146"
"144025036146"
y >= 1900
y <= 1999
y >= 1700
y <= 1799
y >= 1800
y <= 1899
y >= 2000
y <= 2099
y >= 2100
y <= 2199
(yr + (yr
y4) +
+ d +
m <> 2
"31,28,31,30,31,30,31,31,30,31,30,31"
displayDate m, y
%"M"
buildcal
setup
displayDate
weekDay
daysInMonth
setup
bmobutton
byrbutton
currmo
curryear
stilldown
setup
buildcal
getcurrenttime
weekDay
daysInMonth
Whew! It took me
getTime
seconds to draw.
totdays
wrkday
weekDay
034025036146
144025036146
mfactor
cfactor
leapyear
daysInMonth
31,28,31,30,31,30,31,31,30,31,30,31
leapyear
displayDate
bmobutton
byrbutton
hilight
false
byrbutton
4currmo, curryear, stilldown, setup
"frame2"
B"byrbutton" = 1700
B"bmobutton"
"January"
displaydate
buildcal
buttonup
buttonstilldown
buttonup
setup
frame2
byrbutton
bmobutton
January
displaydate
frame2
oHSbuildcal
frame2
currmo
curryear
stilldown
setup
buttonstilldown
setup
frame2
byrbutton
bmobutton
January
displaydate
frame2
setup
currmo
curryear
stilldown
4currmo, curryear, stilldown, setup
"frame2"
B"byrbutton" = 2199
B"bmobutton"
"December"
> 12
displaydate
buildcal
> 12
buttonup
buttonstilldown
buttonup
setup
frame2
byrbutton
bmobutton
December
displaydate
frame2
oHSbuildcal
frame2
currmo
curryear
stilldown
setup
buttonstilldown
setup
frame2
byrbutton
bmobutton
December
displaydate
frame2
setup
currmo
curryear
stilldown
4currmo, curryear, stilldown, setup
"frame2"
B"byrbutton" = 1700
displaydate
buildcal
buttonup
buttonstilldown
buttonup
setup
frame2
byrbutton
displaydate
frame2
oHSbuildcal
frame2
currmo
curryear
stilldown
setup
buttonstilldown
setup
frame2
byrbutton
displaydate
frame2
setup
currmo
curryear
stilldown
4currmo, curryear, stilldown, setup
"frame2"
B"byrbutton" = 2199
displaydate
buildcal
buttonup
buttonstilldown
buttonup
setup
frame2
byrbutton
displaydate
frame2
oHSbuildcal
frame2
currmo
curryear
stilldown
setup
buttonstilldown
setup
frame2
byrbutton
displaydate
frame2
setup
currmo
curryear
stilldown
bmobutton
A Tale of Two Border Styles
vs...
A Slow Boat to China Styles
Rounded edged objects take as much as 12 times the time to image as objects with sharp corners. For best performance, avoid their use. Click the green arrow buttons on each calendar to see the difference.
seconds to clear the text of each field without using sysLockScreen.
Clearing Fields w/o SysLockScreen
"Please click the
getcurrenttime()
"However,
only took" && getTime(
) && "
TRUE,
FFALSE."
buttonup
buttonup
Please click the blue button first.
getcurrenttime
However, it only took
getTime
seconds when sysLockScreen was set to TRUE, then FALSE.
Clear w/ SysLockScreen
The 4 blue buttons clear the text of these fields in different ways. Click the yellow button to put text into the fields, then try the blue buttons to clear the text.
4doneit
reset
85,1410
40,2610
answer
explain
enterpage
reset
enterpage
reset
doneit
reset
explain
answer
-n.8/
4doneit
currObj
k2 = 0
getcurrenttime()
+ 1000
H100,0
p> 8130
H-100,0
H100,0
reset
buttonup
buttonup
getcurrenttime
getcurrenttime
reset
currObj
doneit
Start The Race
Which are faster, paint objects or groups?
Sometimes its better to use a paint object than a group if the group is small
and complicated. What do you think will be faster in this race?
:PHYSSIZE
"""""
""""
"" "
"" ""
" """
" "
" """" """ """""
""" """""
"""""
"""""
""""" """"
""""" "
""""""" """"
"""""" """
"" """""""
""""""" """
""""" """""
"""""
"" """""
"""" """""""""""
""""""" """""
""""""""""
""""""" """" """""""""""
"" """"""""
"""""""""
"" """"""""""" " """""""""
"" " """""""""
"""""""""
""""""""""
""""""""
"""""""""
""""""""
""""""
"""""""""
""""""
""""""""
""""""""""""""
""""""""""""" "
"""""""""""""
""""""
" "
V*` &
answer
This was the group.
This was the paint object..
Bets on the paint object:
Bets on the group:ects
00ts on the paint object:
06ts on the group:ects
Sometimes it's better to use a paint object than a group if the group is small and complicated. What do you think will be faster in this race?
buttonup
buttonup
buttonup
buttonup
buttonup
buttonup
buttonup
buttonup
4doneit
"Hey, you haven't even
the race yet!"
answer
buttonup
buttonup
Hey, you haven't even run the race yet!
answer
doneit
And The Winner Is...
"explain"
buttonup
buttonup
explain
How This Was Done
explain
An loop allowed each object to move 100 page units as many times as it could in 1 second until that object crossed the finish line.ge units as many times as it could.